//
//  UIImageView+Extension.m
//  JiaoX
//
//  Created by yinqy on 15/1/20.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "UIImageView+Extension.h"
#import "UIImageView+WebCache.h"

@implementation UIImageView (Extension)
- (void)sd_setImageWithURL:(NSURL *)url{
    //UIViewContentModeScaleAspectFill //会保证图片比例不变，而且全部显示在ImageView中，这意味着ImageView会有部分空白
    //UIViewContentModeScaleToFill //默认的
    AppDelegate *myDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    if (myDelegate.isCanLoadPic || [Utils isWifi]) {
        [self setContentMode:UIViewContentModeScaleAspectFit];
        [self sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"bg_placeholder"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            [self setContentMode:UIViewContentModeScaleToFill];
        }];
    }else{
        [self setContentMode:UIViewContentModeScaleAspectFit];
        [self setImage:[UIImage imageNamed:@"bg_placeholder"]];
    }
}


@end
